﻿Imports OMANE.Common.UI
Imports System.Windows.Data
Imports System.Windows.Media.Imaging

''' <summary>
''' 
''' </summary>
''' <remarks></remarks>
Public Class CommandToIconConverter
    Implements IValueConverter

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
        'If targetType IsNot GetType(ImageSource) Then _
        '    Throw New InvalidOperationException("La cible doit être de type System.Windows.Media.ImageSource")
        'If Not TypeOf (value) Is ViewModelCommand Then _
        '    Throw New InvalidOperationException("La cible doit être de type TauxGaranti.ViewModels.ViewModelCommand")
        ''Try
        ''    'If value.GetType Is GetType(ViewModels.ViewModelCmdEncoursCorresp) Then
        ''    '    Return createBitmapImage(New Uri("../../Images/bricks.png", UriKind.Relative))
        ''    'ElseIf value.GetType Is GetType(ViewModels.ViewModelCmdEncoursImport) Then
        ''    '    Return createBitmapImage(New Uri("../../Images/chart_pie.png", UriKind.Relative))
        ''    'Else
        ''    '    Return createBitmapImage(New Uri("../../Images/chart_pie.png", UriKind.Relative))
        ''    'End If
        ''Catch ex As Exception
        ''    Return DependencyProperty.UnsetValue
        ''End Try
        Return createBitmapImage(New Uri("../../Images/chart_pie.png", UriKind.Relative))
    End Function

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Public Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
        Throw New NotImplementedException()
    End Function

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Private Function createBitmapImage(ByVal Uri As Uri) As BitmapImage
        Dim result As BitmapImage = New BitmapImage
        result.BeginInit()
        result.UriSource = Uri
        result.EndInit()
        Return result
    End Function

End Class
